<template>
  <div>
    <el-radio-group v-model="select1" @input="selectChannel">
      <el-radio-button label="1">全部稿件</el-radio-button>
      <el-radio-button label="0">草稿</el-radio-button>
    </el-radio-group>
    <div v-for="(item, index) in videoList" style="margin-top: 5px " :key="item.id">
      <div @click="$router.push(`/video/${item.id}`)" v-show="item.status === 1">
        <img :src="item.videoCover" style="width: 300px; height: 168px">
        <div style="font-size: 15px"> {{ item.videoName }} </div>
        <br>
        <div style="font-size: 13px"> {{ item.videoAuthor }} - {{ item.videoDate }} </div>
      </div>
      <div v-show="item.status !== 1">
        <img :src="item.videoCover" style="width: 300px; height: 168px">
        <div style="display: inline-block;"> <el-button @click="$router.push(`/submissionVideo/${item.id}`)"> 修改 </el-button> </div>
        <div style="display: inline-block;"> <el-button @click="publish(item)"> 发布 </el-button> </div>
        <div style="font-size: 15px"> {{ item.videoName }} </div>
        <br>
        <div style="font-size: 13px"> {{ item.videoAuthor }} - {{ item.videoDate }} </div>
      </div>
    </div>
  </div>

</template>

<script>
import { listVideo, updateVideo } from '@/api/video'

export default {
  data () {
    return {
      select1: 1,
      videoList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        status: 1,
        videoType: 0
      }
    }
  },
  async created () {
    const res = await listVideo(this.queryParams)
    this.videoList = res.data.rows
  },
  methods: {
    async selectChannel (status) {
      this.queryParams.status = status
      const res = await listVideo(this.queryParams)
      this.videoList = res.data.rows
    },
    async publish (item) {
      item.status = 1
      await updateVideo(item)

      this.videoList = this.videoList.filter(now => now.id !== item.id)
    }
  }
}
</script>

<style scoped lang="less">

</style>
